import re


def main():
    names = ["name1", "_name", "2_name", "__name__", "a#123"]
    for name in names:
        # 第一位至少是字母或者下划线
        ret = re.match(r"^[a-zA-Z_]+[\w]*$", name)
        if ret:
            print("变量名 %s 符合要求" % ret.group())
        else:
            print("变量名%s 不符合要求" % name)


if __name__ == '__main__':
    main()
